﻿<?php
!defined('EMLOG_ROOT') && exit('access deined!');
function plugin_setting_view(){
$u = BLOG_URL."/admin/plugin.php?plugin=hdengp";

if($_GET['upl'] == ""){
$result = mysql_query("select COUNT(*) AS total from ".DB_PREFIX."hdengp");
$num = mysql_fetch_row($result); //统计行数echo $num;
?>
<form action="<?php echo BLOG_URL."/admin/plugin.php?plugin=hdengp" ?>&px=<?php echo $num["0"]; ?>" method="post" name="frm">
<?php 
$hdengp_s = mysql_query("SELECT * FROM ".DB_PREFIX."hdengp ORDER BY  `a` asc ");
while ($whi = mysql_fetch_array($hdengp_s)) {
?>
<br />
序号：
<input type="text" style="width:20px"  value="<?php echo $whi['a']; ?>" name="ipx[]"/>
<input type="text" style="display:none;" value="<?php echo $whi['id']; ?>" name="tid[]"/>
&nbsp;标题：
<span><?php echo $whi['t']; ?></span>&nbsp;&nbsp;<a href="<?php echo $u."&del=".$whi['id'];?>">删除</a>-
<a href="<?php echo $u."&upl=".$whi['id'];?>">修改</a><BR />
<?php 
}
?>
<br />
<input type="submit" value="排序" />
</form>

<br /><br />
<a onClick="huifd1();" href="javascript:void(0)" id="ahd1">插入幻灯片</a>
<div id="hd1" style="display:none;" >
<form action="<?php echo $u; ?>&ins=1" method="post" name="frm">
<br />

幻灯片序号：
<input type="text" style="width:150px"  name="a"/>
<br /><br />
幻灯片标题：
<input type="text" style="width:150px"  name="t"/>
<br /><br />
幻灯片地址：
<input type="text" style="width:150px"  name="u"/>
<br /><br />
幻灯片图片：<br />
 <iframe frameborder="0" height="80" width="340" name="upload" src="<?php echo BLOG_URL; ?>/content/plugins/hdengp/sc.php"></iframe><br />
<input id="file" name="i" value="" />
<script>
function backfn(fname){
 document.getElementById("file").value=fname;
}
</script>

<br /><br />幻灯片描述:<br />
<textarea rows="5" cols="30" name="m" ></textarea>
<input type="submit" value="确定" />
</form>
</div>

<?php }else{ 

$upl = $_GET['upl'];
$hdengp_s = mysql_query("SELECT * FROM ".DB_PREFIX."hdengp WHERE id = '$upl'");
while ($whi = mysql_fetch_array($hdengp_s)) {
?>

<form action="<?php echo BLOG_URL."/admin/plugin.php?plugin=hdengp" ?>&g=<?php echo $upl; ?>" method="post" name="frm">
<br />
幻灯片序号：
<input type="text" style="width:150px"  value="<?php echo $whi['a']; ?>" name="a"/>
<br /><br />
幻灯片标题：
<input type="text" style="width:150px" value="<?php echo $whi['t']; ?>"  name="t"/>
<br /><br />
幻灯片地址：
<input type="text" style="width:150px" value="<?php echo $whi['u'] ?>"  name="u"/>
<br /><br />
幻灯片图片：<br />
 <iframe frameborder="0" height="80" width="340" name="upload" src="<?php echo BLOG_URL; ?>/content/plugins/hdengp/sc.php"></iframe><br />
<input id="file" name="i" value="<?php echo $whi['i']; ?>" />
<script>
function backfn(fname){
 document.getElementById("file").value=fname;
}
</script><br /><br />
<textarea rows="5" cols="30" name="m" ><?php echo $whi['m']; ?></textarea>
<input type="submit" value="确定" />
</form>

<?php }
}

if($_GET['px'] != ""){
$p_id = $_GET['px'];
$sort = $_POST['ipx'];
$tid  = $_POST['tid'];
$fod = "1";
for($i=0;$i<$p_id;$i++){
$or = $fod++;
mysql_query("update ".DB_PREFIX."hdengp SET a = '".$sort[$i]."' WHERE id = '".$tid[$i]."'");
if($or == $p_id){
?>
<script>alert("排序成功！");
window.location.href="<?php echo $u; ?>";
</script>
<?php 
}
}
}

if($_GET['g'] != ""){
$a = $_POST['a'];
$id = $_GET['g'];
$t = $_POST['t'];
$u = $_POST['u'];
$i = $_POST['i'];
$m = $_POST['m'];
$upl = mysql_query("update ".DB_PREFIX."hdengp SET a = '$a',t = '$t',u ='$u',i = '$i' ,m = '$m' WHERE id = '$id'");
if($upl == "1"){
?>
<script>alert("修改幻灯片成功！");
window.location.href="<?php echo $u; ?>";
</script>
<?php 
}
}


if($_GET['del'] != ""){
$del = $_GET['del'];
$pd_del = mysql_query("DELETE FROM ".DB_PREFIX."hdengp WHERE id ='$del'");
if($pd_del == "1"){
?>
<script>alert("删除幻灯片成功！");
window.location.href="<?php echo $u; ?>";
</script>
<?php 
}
}


if($_GET['ins'] == "1"){
$a = $_POST['a'];
$t = $_POST['t'];
$u = $_POST['u'];
$i = $_POST['i'];
$m = $_POST['m'];
$ins = mysql_query("INSERT INTO ".DB_PREFIX."hdengp (a,t,i,u,m) VALUES ('$a','$t','$i','$u','$m')");
if($ins == "1"){
?>
<script>alert("插入幻灯片成功！");
window.location.href="<?php echo $u; ?>";
</script>
<?php 
}
}
?>

<script type="text/javascript">
function setFile(f1){
document.frm.logoImg.value=f1;
}
	 
function huifd1(){
   var target=document.getElementById("hd1");
   var clicktext=document.getElementById("ahd1");
            if (target.style.display=="block"){
                target.style.display="none";
                clicktext.innerText="插入幻灯片";
            } else {
                target.style.display="block";
                clicktext.innerText='取消插入';
            }
}

function int(){
   var target=document.getElementById("intdivid");
   var clicktext=document.getElementById("intid");
            if (target.style.display=="block"){
                target.style.display="none";
                clicktext.innerText="修改";
            } else {
                target.style.display="block";
                clicktext.innerText='取消';
            }
}
</script>
<?php 
}?>
